<template>
  <div class="integralDetails">
    <PageContainer title="积分详情" back no-tab>
      <Member></Member>
      <div class="big-title">积分变动详情</div>
      <AutofixScroll :height="height" @bottom="onBottom">
        <div class="integral-list">
          <div v-for="(item, index) in list" :key="index" class="integral-item">
            <div class="integral-info">
              <div class="title">{{ item.name }}</div>
              <div class="integral-number">{{ Number(item.changepoint) > 0 ? `+${item.changepoint}` : item.changepoint }}</div>
            </div>
            <div class="time">{{ item.createTime }}</div>
          </div>
        </div>
        <u-loadmore :status="loadStatus" loadmoreText="加载更多" nomoreText="暂无更多积分数据" />
      </AutofixScroll>
    </PageContainer>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import AutofixScroll from '@/components/AutofixScroll/index';
import PageContainer from '@/components/PageContainer/index.vue'
import Member from '@/components/Member/index.vue';
import { erpPointChangeList } from '@/api'

const list = ref([])

const height = `calc(100% - ${uni.upx2px(172)}px)`
const loadStatus = ref('loading')

const params = {
  pageNo: 1,
  pageSize: 10,
}
let total = 0

const getList = async () => {
  loadStatus.value = 'loading'
  try {
    const res = await erpPointChangeList(params)
    list.value = [...list.value, ...(res.records || [])]
    total = res.total
    if (list.value.length >= total) {
    loadStatus.value = 'nomore'
  }
  }finally {

  }
}

const onBottom = () => {
  if (list.value.length >= total) {
    loadStatus.value = 'nomore'
    return
  }
  params.pageNo += 1
  getOrderList()
}

onMounted(() => {
  getList()
})

</script>

<style lang="less" scoped>
.integralDetails {
  .big-title {
    font-size: 18px;
    font-weight: bold;
    color: #151A1D;
    padding: 16px;
    margin-top: 30px;
  }
	.integral-list {
    padding: 0 8px;
    .integral-item {
      width: 100%;
      padding: 16px 8px;
      box-sizing: border-box;
      background: #fff;
      &:not(:last-child) {
        border-bottom: 1px solid #F6F8FA;
      }

      .integral-info {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 8px;
        .title {
          font-size: 14px;
          font-weight: 400;
          color: #282828;
          overflow:hidden;
          text-overflow:ellipsis;
          display:-webkit-box;
          -webkit-box-orient:vertical;
          -webkit-line-clamp:2;
        }

        .integral-number {
          font-size: 16px;
          font-weight: bold;
        }
      }

      .time {
        font-size: 12px;
        font-weight: 500;
        color: #939393;
      }
    }
  }
}
</style>
